package com.kaili.basic.scheduler;

import com.kaili.basic.service.IDeviceSignService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;


/**
 * @Desc: 设备签到监听
 * @author: zhouyijian
 * @Time: 2019/8/8 15:47
 * @Copyright: © 2018 杭州凯立通信有限公司 版权所有
 * @Warning: 本内容仅限于公司内部传阅, 禁止外泄或用于其它商业目的
 */

public abstract  class DeviceSignListener implements ServletContextListener {

    @Autowired
    private TaskScheduler task;
    @Autowired
    private IDeviceSignService deviceSignService;

    private Logger logger = LoggerFactory.getLogger(DeviceSignListener.class);

    public void  contextInitialized(ServletContextEvent event){
        task =new TaskScheduler(deviceSignService);
        task.start();
        if (logger.isInfoEnabled()) {
            logger.info("+++++++++++++++++++++++++++定时签到任务开始+++++++++++++++++++++++++");
            }
        }



    public void  contextDestroyed(ServletContextEvent event){
        if(task!=null){
            task.shutdown();

            if (logger.isInfoEnabled()) {
                logger.info("+++++++++++++++++++++++++++定时签到任务结束+++++++++++++++++++++++++");
            }
        }
    }


}
